package com.lcz.fruitweb.service.impl;

import com.lcz.fruitweb.dao.FruitDao;
import com.lcz.fruitweb.service.FruitService;
import model.Fruit;

import java.util.List;

/**
 * 业务要做通知的事情
 *
 * @author 才智
 */
public class FruitServiceImpl implements FruitService {
    //    private FruitDao fruitDao=new FruitDaoJdbcImpl();
    //    private FruitDao fruitDao = new FruitDaoMybatisImpl();
    private FruitDao fruitDao;
    public void setFruitDao(FruitDao fruitDao){
        System.out.println("======================="+fruitDao.getClass());
        this.fruitDao = fruitDao;
    }
    @Override
    public boolean saveFruit(Fruit fruit) {
        fruitDao.save(fruit);
        return false;
    }

    @Override
    public void delFruitById(int id) {
        fruitDao.del(id);
    }

    @Override
    public Fruit findFruitById(int id) {
        return fruitDao.findById(id);
    }

    @Override
    public boolean updateFruit(Fruit fruit) {
        return fruitDao.update(fruit);
    }

    @Override
    public List<Fruit> findAllFruits() {
        return fruitDao.findAll();
    }
}
